float sdCircle(vec2 p,float r){
    return length(p)-r;
}
float sdBox(in vec2 p,in vec2 b)
{
    vec2 d=abs(p)-b;
    return length(max(d,0.))+min(max(d.x,d.y),0.);
}
float sdEquilateralTriangle(in vec2 p,in float r)
{
    const float k=sqrt(3.);
    p.x=abs(p.x)-r;
    p.y=p.y+r/k;
    if(p.x+k*p.y>0.)p=vec2(p.x-k*p.y,-k*p.x-p.y)/2.;
    p.x-=clamp(p.x,-2.*r,0.);
    return-length(p)*sign(p.y);
}
mat2 rotation2d(float angle){
    float s=sin(angle);
    float c=cos(angle);

    return mat2(
        c,-s,
        s,c
    );
}

vec2 rotate(vec2 v,float angle){
    return rotation2d(angle)*v;
}
float opRound(in float d,in float r)
{
    return d-r;
}

float opOnion(in float d,in float r)
{
    return abs(d)-r;
}

void mainImage(out vec4 fragColor,in vec2 fragCoord){
    vec2 uv=fragCoord/iResolution.xy;
    
    uv=(uv-.5)*2.;
    uv.x*=iResolution.x/iResolution.y;
    // 翻转
    // uv.y*=-1.;
    uv = rotate(uv,iTime);

    float d=sdEquilateralTriangle(uv,0.3);
    d = opRound(d,0.09);
    d = opOnion(d,0.01);
    float c=smoothstep(0.,.0009,d);
    
    if(length(uv)<=.02){
        fragColor=vec4(vec3(1,1,1),1.);
    }else{
        fragColor=vec4(vec3(c),1.);
    }    
}